package com.sita.linboard.wallet;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sita.linboard.R;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Jason on 2016/9/27.
 */
public class WithdrawaAdapter extends BaseAdapter {
    private List<WithdrawBackBean.DataBean> data;
    private Context context;

    public WithdrawaAdapter(Context context) {
        data = new ArrayList<>();
        this.context = context;
    }
    public void setData(List<WithdrawBackBean.DataBean> dataBeen){
        data = dataBeen;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder holder = null;
        if (convertView==null){
            holder= new MyViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_withdraw,parent,false);
            holder.balance = (TextView) convertView.findViewById(R.id.balance);
            holder.money = (TextView) convertView.findViewById(R.id.withdraw_money);
            holder.time = (TextView) convertView.findViewById(R.id.withdraw_time);
            convertView.setTag(holder);
        }
        else {
            holder = (MyViewHolder) convertView.getTag();
        }
        holder.time.setText(data.get(position).getTradeTime().substring(0,4)+"-"+data.get(position).getTradeTime().substring(4,6)+"-"+data.get(position).getTradeTime().substring(6,8));
        holder.money.setText(String.valueOf(data.get(position).getMoney()));
        holder.balance.setText("余额: "+String.valueOf(data.get(position).getBalance()));
        return convertView;
    }
    class MyViewHolder{
           TextView time,money,balance;
    }
}
